from abc import ABC, abstractmethod
from typing import Optional, Any, Dict, List, Union
from pydantic import BaseModel, Field, HttpUrl
from threading import Lock
import requests
from Logger import Logger

# 配置日志
logger = Logger.get_logger(__name__)

# 定义响应模型
class EmbeddingResponse(BaseModel):
    data: Optional[List[Dict[str, Any]]] = None
    model: Optional[str] = None
    object: Optional[str] = None
    usage: Optional[Dict[str, int]] = None
    error: Optional[Dict[str, Any]] = None

class EmbeddingClientBase(ABC):
    """嵌入服务统一接口"""
    
    @abstractmethod
    def get_embeddings(self, input_text: Union[str, List[str]]) -> EmbeddingResponse:
        """
        获取文本嵌入向量
        
        :param input_text: 输入文本或文本列表
        :return: EmbeddingResponse
        """
        pass
